#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>

int My_atoi(const char *str)
{
    assert(str);
    int num = 0;
    int flag = 1;
    while (isspace(*str))
    {
        str++;
    }
    if (isalpha(*str))
    {
        return 0;
    }
    else
    {
        if (*str == '-')
        {
            flag = -1;
            str++;
        }
        while (isdigit(*str))
        {
            num = num * 10 + *str - '0';
            str++;
        }
    }
    return num * flag;
}

int main()
{
    char arr[] = {"  \n   \n -123\tabcwe 345"};
    int val1 = atoi(arr);
    int val2 = My_atoi(arr);
    printf("%d\n", val1);
    printf("%d\n", val2);
    return 0;
}